#include <bits/stdc++.h>

using namespace std;

int n, res = 0;
map<int, int> attack_con, live_con;
priority_queue<int, vector<int>, greater<int> > attack_pq, live_pq;

int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++){
        int cur;
        cin >> cur;
        if(attack_con.find(cur) != attack_con.end()){
            attack_con[cur] += 1;
            live_con[cur] += 1;
        } else {
            attack_con.insert(make_pair(cur, 1));
            live_con.insert(make_pair(cur, 1));
        }
    }
    for(auto it = attack_con.begin(); it != attack_con.end(); it++){
        // cout << it -> first << " : " << it->second << endl;
        attack_pq.push(it->first);
        live_pq.push(it->first);
    }
    attack_pq.pop();
    while(!attack_pq.empty()){
        int attack = attack_pq.top();
        int live = live_pq.top();
        // cout << attack << " : " << live << endl;
        // attack_pq.pop();
        // cout << attack << " :: " << attack_con[attack] << endl;
        // cout << attack_pq.size() << endl;
        // while(attack <= live){
            // cout << attack_pq.size() << endl;
            // if(attack_pq.size() == 1 && attack == live){
                // cout << "here" << endl;
                // break;
            // }
            // break;
        if(attack <= live && attack_pq.size() != 1){
            attack_pq.pop();
            attack = attack_pq.top();
        } else if(attack <= live && attack_pq.size() == 1){
            break;
        }
        // }
        if(attack_con[attack] > live_con[live]){
            live_con[live] = 0;
            attack_con[attack] = attack_con[attack] - live_con[live];
            live_pq.pop();
        }
        if(attack_con[attack] == live_con[live]){
            live_con[live] = 0;
            attack_con[attack] = 0;
            live_pq.pop();
            attack_pq.pop();
        }
        if(attack_con[attack] < live_con[live]){
            live_con[live] = live_con[live] - attack_con[attack];
            attack_con[attack] = 0;
            attack_pq.pop();
        }
    }
    for(auto it = live_con.begin(); it != live_con.end(); it++){
        res += it->second;
        // pq.push(it->first);
        // cout << it -> second << endl;
    }
    cout << res << endl;
    return 0;
}